import Vue from 'vue';
import VueRouter from 'vue-router';
import Element from 'element-ui';
import $ from 'jquery';
import {router} from './router/index';
import { appRouter } from './router/router';
// import util from './libs/util';
import store from './store/';
import core from '@/js/core';       // 公共指令及filter
import 'font-awesome/css/font-awesome.min.css';
import iView from 'iview';
import 'iview/dist/styles/iview.css';
// import BaiduMap from 'vue-baidu-map';

window.$ = $;
Vue.config.productionTip = false;

Vue.use(iView);
Vue.use(VueRouter);
Vue.use(Element);
Vue.use(core);
// Vue.use(BaiduMap, {
//   ak: 'hZSj3ImvmHUOpIGPTKZr5NPftcYNpKW1'
// });
Vue.config.lang = 'zh-CN';
// const router = new VueRouter({
//   mode: 'history',
//   routes,
//   strict: process.env.NODE_ENV !== 'production'
// });
//
// // 路由未登录拦截
// router.beforeEach((to, from, next) => {
//   next();
// });

/* eslint-disable no-new */
new Vue({
  router,
  store,
  data: {
    currentPageName: ''
  },
  mounted () {
    this.currentPageName = this.$route.name;
    // 显示打开的页面的列表
    this.$store.commit('setOpenedList');
    this.$store.commit('initCachepage');
    // 权限菜单过滤相关
    // this.$store.commit('updateMenulist');
    // iview-admin检查更新
    // util.checkUpdate(this);
  },
  created () {
    let tagsList = [];
    appRouter.map((item) => {
      // tagsList.push(item.children[0]);
      if (item.children.length <= 1) {
        tagsList.push(item.children[0]);
      } else {
        tagsList.push(...item.children);
      }
    });
    this.$store.commit('setTagsList', tagsList);
  }
}).$mount('#app');
